package com.share.rule.api;

import com.share.common.core.domain.R;
import com.share.rule.domain.FeeRule;
import com.share.rule.domain.FeeRuleRequestForm;
import com.share.rule.domain.FeeRuleResponse;
import com.share.rule.domain.FeeRuleResponseVo;
import com.share.rule.service.IFeeRuleService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ZhouShuang
 * @version 17
 * @Title
 * @date 2025/10/20 上午11:03
 */
@Slf4j
@RestController
@RequiredArgsConstructor()
@RequestMapping("/feeRule")
public class FeeRuleApiController {
    private final IFeeRuleService feeRuleService;

    /**
     * 批量获取费用规则的信息
     */
    @Operation(summary = "批量获取费用规则信息")
    @PostMapping("/getFeeRuleList")
    public R<List<FeeRule>> getFeeRuleList(@RequestBody List<Long> feeRuleIds){
        return R.ok(feeRuleService.listByIds(feeRuleIds));

    }

    /**
     * 获取费用规则详细信息
     * @param id
     * @return
     */
    @Operation(summary = "获取费用规则详细信息")
    @GetMapping("/getFeeRule/{id}")
    public R<FeeRule> getFeeRule(@PathVariable Long id){
        return R.ok(feeRuleService.getById(id));
    }

    /**
     * 计算订单费用
     * @param requestForm
     * @return
     */
    @Operation(summary = "计算订单费用")
    @PostMapping("/calculateOrderFee")
    public R<FeeRuleResponseVo> calculateOrderFee(@RequestBody FeeRuleRequestForm requestForm){
        return R.ok(feeRuleService.calculateOrderFee(requestForm));
    }
}
